<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%-- <div class="pagination">
	<c:forEach begin="${pageView.pageindex.startindex}" end="${pageView.pageindex.endindex}" var="wp">
    <c:if test="${pageView.currentpage==wp}"><span class="page">${wp}</span></c:if>
    <c:if test="${pageView.currentpage!=wp}"><span><a href="javascript:topage('${wp}')">&nbsp;${wp}&nbsp;</a></span></c:if>
    </c:forEach>
    <span>当前页:第${pageView.currentpage}页 | 总记录数:${pageView.totalrecord}条 | 每页显示:${pageView.maxresult}条 | 总页数:${pageView.totalpage}页</span>
</div> --%>
<!--page-->
<div class="pages">
    <ul>
	  <li class="pre">
	  	<c:choose>
  			<c:when test="${pageView.currentpage > 1}">
  				<span onclick="goTo('${pageView.currentpage - 1}')">Previous page</span>
   			</c:when>
   			<c:otherwise>
   				<span>Previous page</span>
   			</c:otherwise>
   		</c:choose>
	  </li>
		<c:forEach begin="${pageView.pageindex.startindex}" end="${pageView.pageindex.endindex}" var="wp">
			<c:if test="${pageView.currentpage==wp}"><li class="page_list curr"><span><a>${wp}</a></span></li></c:if>
			<c:if test="${pageView.currentpage!=wp}"><li class="page_list"><span><a href="javascript:goTo('${wp}')">${wp}</a></span></li></c:if>
		</c:forEach>
	  <li class="pre">
	  	<c:choose>
  			<c:when test="${pageView.currentpage < pageView.totalpage}">
  				<span onclick="goTo('${pageView.currentpage + 1}')">Next page</span>
  			</c:when>
  			<c:otherwise>
  				<span>Next page</span>
  			</c:otherwise>
  		</c:choose>
	  </li>
	  <li style="padding-left: 10px;">${pageView.totalpage} Pages , Go&nbsp;</li>
	  <li><input type="number" style="width:50px; height:25px;" id="number" value="${pageView.currentpage}" max="${pageView.totalpage }" min="1" /></li>
	  <li>&nbsp;Page&nbsp;</li>
	  <li class="pre"><span onclick="goTo(document.getElementById('number').value)">Confirm</span></li>
	</ul>
  </div>
  
<script>
	var url = '';
	$(document).ready(function(){
		$(".page_list").click(function(){
			$(this).addClass("curr").siblings().removeClass("curr");
		});
		
		//分页的请求路径
		url = '${root }${reqUrl}?${cityValue}';
	});
	//分页查询
	function goTo(number){
		//总页数(最大的页数)
		var totalpage = ${pageView.totalpage};
		//当前页
		var currentpage = ${pageView.currentpage};
		//跳转页面时,判断跳转的页面是否合理
		if(number != null && number != currentpage && number > 0 && number <= totalpage){
			var param = $('#searchForm').serialize();
			url = url+"&"+param+'&page='+ number; 
			window.location.href = url;
		}
	}
</script>
<!--end page-->
